From 334ed7f65e426e7acd7923a23054294de9a4293a Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 13 Jan 2009 15:16:07 +0000 Subject: [PATCH] AMD IOMMU: Fix a dead lock in device assignment. Do not obtain pcidevs_lock in reassign_device(). Signed-off-by: Wei Wang --- xen/drivers/passthrough/amd/pci_amd_iommu.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index ec26a9a19d..53eff979a4 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -271,26 +271,22 @@ static int reassign_device( struct domain *source, struct domain *target, struct amd_iommu *iommu; int bdf; - spin_lock(&pcidevs_lock); + ASSERT(spin_is_locked(&pcidevs_lock)); pdev = pci_get_pdev_by_domain(source, bus, devfn); if ( !pdev ) - { - spin_unlock(&pcidevs_lock); return -ENODEV; - } bdf = (bus << 8) | devfn; /* supported device? */ iommu = (bdf < ivrs_bdf_entries) ? - find_iommu_for_device(bus, pdev->devfn) : NULL; + find_iommu_for_device(bus, pdev->devfn) : NULL; if ( !iommu ) { - spin_unlock(&pcidevs_lock); amd_iov_error("Fail to find iommu." - " %x:%x.%x cannot be assigned to domain %d\n", - bus, PCI_SLOT(devfn), PCI_FUNC(devfn), target->domain_id); - return -ENODEV; + " %x:%x.%x cannot be assigned to domain %d\n", + bus, PCI_SLOT(devfn), PCI_FUNC(devfn), target->domain_id); + return -ENODEV; } amd_iommu_disable_domain_device(source, iommu, bdf); -- 2.30.2